package org.abc.fund.repository.funds;

import org.abc.fund.entity.funds.FundFinIndicator;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.Optional;

/**
 * Repository for FundFinIndicator entity.
 */
@Repository
public interface FundFinIndicatorRepository extends JpaRepository<FundFinIndicator, Long> {
    /**
     * 根据基金代码和统计日期查找财务指标记录
     */
    Optional<FundFinIndicator> findByFundCodeAndStatisticDate(String fundCode, LocalDate statisticDate);
    
    /**
     * 根据基金代码查找最新的财务指标记录（按统计日期降序）
     */
    Optional<FundFinIndicator> findTopByFundCodeOrderByStatisticDateDesc(String fundCode);

    @Modifying
    @Transactional
    void deleteByFundCodeAndStatisticDateBetween(String fundCode, LocalDate startDate, LocalDate endDate);
}






